package com.travelshare.common.core.domain;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.travelshare.common.core.domain.entity.CommunityData;

public class TreeCommunity implements Serializable
{
    private static final long serialVersionUID = 1L;
    
    private Long id;
    private String content;
    private String nickName;
    private String avatar;
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date releaseTime;
    private boolean showReply;
	private String picPath;
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<TreeCommunity> children;
	public TreeCommunity() {
	}
	
	public TreeCommunity(CommunityData communityData)
    {
        this.id = communityData.getCommunityId();
        this.content = communityData.getContent();
        this.nickName = communityData.getNickName();
        this.avatar = communityData.getAvatar();
        this.releaseTime = communityData.getReleaseTime();
        this.showReply = communityData.getParentId().longValue() != 0;
        this.picPath = communityData.getPicPath();
        this.children = communityData.getChildren().stream().map(TreeCommunity::new).collect(Collectors.toList());
    }
	
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public String getNickName() {
		return nickName;
	}
	public void setNickName(String nickName) {
		this.nickName = nickName;
	}
	public String getAvatar() {
		return avatar;
	}
	public void setAvatar(String avatar) {
		this.avatar = avatar;
	}
	public Date getReleaseTime() {
		return releaseTime;
	}
	public void setReleaseTime(Date releaseTime) {
		this.releaseTime = releaseTime;
	}
	public boolean isShowReply() {
		return showReply;
	}
	public void setShowReply(boolean showReply) {
		this.showReply = showReply;
	}
	public List<TreeCommunity> getChildren() {
		return children;
	}
	public void setChildren(List<TreeCommunity> children) {
		this.children = children;
	}

	public String getPicPath() {
		return picPath;
	}

	public void setPicPath(String picPath) {
		this.picPath = picPath;
	}
}
